import axios from '@/utils/plugins/request'
import Qs from 'qs'
import {serviceName,loginServiceName} from '@/const.config.js'

/**
 * 客户端形式获取scrf_token,用来获取验证码使用
 * @param {Object} params
 */
export const getCsrf = (params) => {
    return axios({
        url: serviceName+'/rest/system/common/csrf',
        method: 'GET',
        params
    })
}

/**
 * 系统登录的token
 * @param data 登录的数据
 * @param headers 登录时的请求头信息 包含加密
 * @returns {*} token 信息
 */
export const getToken = (data,headers)=>{
    return axios({
        url:loginServiceName+"/oauth/token",
        method:"post",
        data:Qs.stringify(data),
        headers
    })
}

/**
 * 获取密码加密的公钥
 * @param params
 * @returns {AxiosPromise}
 */
export const getPubKey = (params = {}) => {
    return axios({
        url: loginServiceName+'/oauth/getKeystr',
        method: 'get',
        params: params
    })
}